home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / KB-INKEY.DMO < prev    next >
Text File  |  1996-07-04  |  3KB  |  55 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   KB-INKEY.DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22. COLOR 7, 0
  23. CLS
  24.  
  25. ? "┌────────────────────────────────────────────────────────────────────
  26. ? "│ fINKEY%  ( ScanCode?, AsciCode? )
  27. ? "│ fINSTAT% ( ScanCode?, AsciCode? )
  28. ? "├───────────────────────────────────────────────────────────────────────
  29. ? "│ There are times when it is preferable to know which of the keys were
  30. ? "│ pressed and not just the ASCII value that was stuffed into the buffer.
  31. ? "│ Little things like non-English keyboard drivers may think that the Z key
  32. ? "│ really should send a Y or some such thing! But, by working with the
  33. ? "│ keyboard's scan codes you can tell actually WHICH key was pressed so your
  34. ? "│ program can determine the proper course of action.
  35. ? "│ As you work the short program, below, watch the values returned for the
  36. ? "│ function keys, arrow keys, etc. they may just look familiar!
  37. ? "├─────────────────────────────────────────────────────────────────────────
  38. ? "│ OH! almost forgot... fINSTAT% reads the keyboard buffer but does
  39. ? "│                               NOT remove any key press found there.
  40. ? "│                      BOTH     return  0 if no key press was present
  41. ? "│                               and -1 if there was.
  42. ? "└─────────────────────────────────────────────────────────────────────────
  43. ? " PRESS <ESC> TO END THE PROGRAM"
  44. ?
  45.                                                '┌───────────────────────────
  46. ClearKeyboard                                  '│ for you F.T.L. types
  47. DO                                             '│
  48.   WHILE NOT fINKEY%( SCode?, ACode? ) : WEND   '│ wait for a key press
  49.   PRINT USING "ScanCode: ###  "; Scode?;       '│ print SCANCODE
  50.   PRINT USING "ASCIIcode: ### "; ACode?        '│ print ASCII VALUE
  51. LOOP UNTIL Acode? = 27                         '│ loop until <ESC> is pressed
  52.                                                '│
  53. PRINT "<< THANK YOU >>"                        '│ Mom said to be polite!
  54.                                                '└───────────────────────────
  55.